/**
 * @addtogroup FPDFAPI
 * @{
 */
   
/**
 * @file
 * @brief Header file for FPDFEMB SDK
 *
 * Copyright (c) 2007-2010 Foxit Corporation, All Right Reserved.
 *
 * Date: 2010-06-29
 *
 * Embedded platforms have many different aspects from desktop platforms,
 * among them, the followings are most important for PDF processing:
 * 
 * 1.	Embedded platforms have only limited memory, and there is no virtual memory.
 *		PDF is a very complicated format, processing PDF may consumes quite
 *		large amount of memory, even for some smaller PDFs. And, in order to 
 *		increase the performance of PDF parsing and rendering, cache memory
 *		is often used. For some big PDFs with many pages, the cache may grow
 *		while user browing through pages, eventually, for some PDFs, the memory
 *		on the device may run out.
 *
 *		FPDFEMB SDK allows graceful out-of-memory (OOM) handling by returning 
 *		OOM error code for all functions that may involve memory allocation. 
 *		When an application detects OOM situation, it can do one of the followings:
 *
 *		a) Give user some prompt and quit the application or close the document;\n
 *		b) Or better, try to recover from the error. Sometimes OOM can be caused
 *				by ever-growing cache. For example, when user browses a 1000-page 
 *				document, let's say OOM happen at page #300. In this case, the
 *				application might close the whole document (cache will be gone with
 *				it), reopen the document, then go directly to page #300. It's likely
 *				the process will go through this time. This is called "OOM recovery".
 *				If OOM happens again during a recovery, then, it's not possible to finish
 *				the process, the application must quit of close the document.
 *
 * 2.	Embedded platforms has only limited computing power. Since some PDFs
 *		can be very complicated and require a lot of processing to be displayed,
 *		it may take a lot of time for the process to finish. This may cause
 *		some problem with user experience, especially for devices like mobile
 *		phones, when an application may need to be put on hold any time. Therefore, 
 *		it's important to break lengthy process into small steps which can be 
 *		stopped or resumed at any time. We call this kind of process as 
 *		"progressive process".
 *
 *		FPDFEMB SDK allows progressive page parsing and rendering, the most time-
 *		consuming part of PDF processing.
 *
 * IMPORTANT:\n
 *		FPDFEMB module is not intended to run in multi-threaded environment.
 *
 * Components inside FPDFEMB:
 * -	* Library Memory Management
 * -	* Document Operations
 * -	* Page Basic Operations
 * -	* Page Parsing
 * -	* Page Rendering
 * -	* Coordination Conversion
 * -	* Text Search
 * -	* Text Information
 * -	* Device Independent Bitmap
 * -	* Custom Font Handler and CJK Support
 * -	* Bookmark Information
 * -	* Hyperlink Information
 * -	* Text Output
 */

#ifndef _FPDFEMB_H_
#define _FPDFEMB_H_

#ifdef __cplusplus
extern "C" {
#endif

/** @brief Standard return type for many FPDFEMB functions: FPDFERR_SUCCESS for success, otherwise error code. */
typedef int FPDFEMB_RESULT;

/** @brief Standard boolean type: 0 for false, non-zero for true. */
typedef int FPDFEMB_BOOL;

/** @brief Unicode character. FPDFEMB uses UTF16LE format for unicode string. */
typedef unsigned short FPDFEMB_WCHAR;

/**
 * @name Error codes for FPDFEMB SDK
 */
/*@{*/

/** @brief Success. */
#define FPDFERR_SUCCESS		0
/** @brief Out of memory. */
#define FPDFERR_MEMORY		1
/** @brief Error of any kind, without specific reason. */
#define FPDFERR_ERROR		2
/** @brief Incorrect password. */
#define FPDFERR_PASSWORD	3
/** @brief File or data format error. */
#define FPDFERR_FORMAT		4
/** @brief File access error. */
#define FPDFERR_FILE		5
/** @brief Parameter error. */
#define FPDFERR_PARAM		6
/** @brief Not in correct status. */
#define FPDFERR_STATUS		7
/** @brief To be continued. */
#define FPDFERR_TOBECONTINUED	8
/** @brief Search result not found. */
#define FPDFERR_NOTFOUND	9

/*@}*/ 

/********************************************************************************************
****
****		Library Memory Management
****
********************************************************************************************/

/**
 * @brief Structure: FPDFEMB_MEMMGR			
 *			Including interfaces implemented by host application, providing memory allocation
 *			facilities. All members are required.
 *			A memory manager structure is required to be valid during the entire period
 *			when an application using FPDFEMB module.
 *
 *			IMPORTANT NOTE: using of this interface is strongly not recommended, because
 *			FPDFEMB now internally use FPDFEMB_MEMMGR_EX interface, which allows more
 *			advanced memory management. This interface is retained for backward compatibility
 *			only, and maybe discontinued in the future.
 */
struct FPDFEMB_MEMMGR {
	/**
	 * @brief Interface: Alloc
	 *		Allocate a memory block.
	 *
	 * Comments:\n
	 *		In order to handle OOM situation, application can use longjmp() inside 
	 *		implementation of this function. If underlying memory manager fails to 
	 *		allocate enough memory, then application can use longjmp() to jump to
	 *		OOM handling codes.
	 *
	 * @param[in] pMgr		Pointer to the memory manager.
	 * @param[in] size		Number of bytes for the memory block.
	 * @return The pointer to allocated memory block. NULL if no memory available.
	 */
	void*	(*Alloc)(struct FPDFEMB_MEMMGR* pMgr, unsigned int size);

	/**
	 * @brief Interface: AllocNL
	 *		Allocate a memory block, without leaving.
	 *
	 * Comments:\n
	 *		Implementation MUST return NULL if no memory available, no exception
	 *		or longjmp() can be used.
	 *
	 * @param[in] pMgr		Pointer to the memory manager.
	 * @param[in] size		Number of bytes for the memory block.
	 * @return The pointer to allocated memory block. NULL if no memory available.
	 */
	void*	(*AllocNL)(struct FPDFEMB_MEMMGR* pMgr, unsigned int size);

	/**
	 * @brief Interface: Realloc
	 *		Reallocate a memory block.
	 *
	 * Comments:\n
	 *		If an existing memory block specified, the data in the memory block will
	 *		be copied to the new block, if reallocated.
	 *
	 *		In order to handle OOM situation, application can use longjmp() inside 
	 *		implementation of this function. If underlying memory manager fails to 
	 *		allocate enough memory, then application can use longjmp() to jump to
	 *		OOM handling codes.
	 *
	 * @param[in] pMgr		Pointer to the memory manager.
	 * @param[in] pointer	An existing memory block, or NULL.
	 * @param[in] new_size	New size (number of bytes) of the memory block. Can be zero.
	 * @return The pointer of reallocated memory block, it could be a new block, or just
	 *		the previous block with size modified.
	 */
	void*	(*Realloc)(struct FPDFEMB_MEMMGR* pMgr, void* pointer, unsigned int new_size);

	/**
	 * @brief Interface: Free
	 *		Free a memory block.
	 *
	 * @param[in] pMgr		Pointer to the memory manager.
	 * @param[in] pointer	An existing memory block.
	 */
	void	(*Free)(struct FPDFEMB_MEMMGR* pMgr, void* pointer);
};

/**
 * @brief Function: FPDFEMB_Init
 *			Initialize the FPDFEMB module.
 *
 * Comments:\n
 *			This function will allocate necessary internal data structure for
 *			the whole module to operate.
 *
 * @param[in] mem_mgr		Pointer to memory manager structure.
 * @return	Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_Init(struct FPDFEMB_MEMMGR* mem_mgr);

/** @brief Fixed memory OOM(out-of-memory) handler type. */ 
typedef void (*FPDFEMB_FIXED_OOM_HANDLER)(void* memory, int size);

/**
 * @brief Function: FPDFEMB_InitFixedMemory
 *			Initialize the FPDFEMB module, providing a fixed memory heap.
 *
 * Comments:\n
 *			In many embedded system, memory usage are predetermined. The application
 *			is assigned with fixed size of available memory, then it can pre-allocate
 *			a memory block with maximum size and pass to this function to initialize
 *			FPDFEMB module. In this case, FPDFEMB won't need any additional memory
 *			allocation.
 *
 *			In case the pre-allocated memory has run out, the "oom_proc" callback
 *			function will be called to notify the application that an OOM recovery
 *			procedure needs to be performed.
 *
 * @param[in] memory		Pointer to a pre-allocated memory block.
 * @param[in] size			Number of bytes in the memory block.
 * @param[in] oom_handler	Pointer to a function which will be called when OOM happens. Can be
 *							NULL if application doesn't want to be notified om OOM.
 * @return	Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_InitFixedMemory(void* memory, int size, FPDFEMB_FIXED_OOM_HANDLER oom_handler);

/**
 * @brief Structure: FPDFEMB_MEMMGR2
 *			Interfaces for extensible fixed memory manager. This kind of memory manager starts with
 *			a fixed memory pool but when it runs out, the manager will call out and ask for more
 *			memory.
 */
struct FPDFEMB_MEMMGR2
{
	/**
	 * @brief Interface: More
	 *		Called when FPDFEMB memory manager needs more memory to allocate some block.
	 * 
	 * @param[in] pMgr			Pointer to this structure.
	 * @param[in] alloc_size	Size of object FPDFEMB is trying to allocate.
	 * @param[out] new_memory	Receiving newly allocated memory pool.
	 * @param[out] new_size		Receiving newly allocated size. This size must be same or bigger than alloc_size.
	 * @return Nonzero for successfully allocated new memory pool, zero for memory not available.
	 */
	FPDFEMB_BOOL (*More)(struct FPDFEMB_MEMMGR2* pMgr, int alloc_size, void** new_memory, int* new_size);

	/**
	 * @brief Interface: Free
	 *		Called when a memory pool become empty and can be released
	 *
	 * @param[in] pMgr			Pointer to this structure
	 * @param[in] memory		Pointer to the memory pool
	 */
	void	(*Free)(struct FPDFEMB_MEMMGR2* pMgr, void* memory);
};

/**
 * Function: FPDFEMB_GetExtralMemoryUsedSize
 *	    Get the size of the occupied memory.	
 *
 * Comments: 	This function is used to count memory applied for by More(), and exclude the part initialized by the FPDFEMB_InitFixedMemory2() .
 *
 * @return size		The size of the occupied memory. 	
 */
int FPDFEMB_GetExtralMemoryUsedSize();


/**
 * @brief Function: FPDFEMB_InitFixedMemory2
 *			Initialize FPDFEMB using an extensible fixed memory manager. With this kind of manager,
 *			when current memory pool runs out, the application may provide some additional memory block
 *			for the manager to use.
 *
 * @param[in] memory			Pointer to a pre-allocated memory block
 * @param[in] size				Number of bytes in the memory block
 * @param[in] callbacks			Callback functions when FPDFEMB runs out of current memory pool, or
 *								when a pool become empty and can be dropped
 * @param[in] oom_handler		Pointer to a function which will be called when OOM happens. Can be
 *								NULL if application doesn't want to be notified om OOM.
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_InitFixedMemory2(void* memory, int size, struct FPDFEMB_MEMMGR2* callbacks, FPDFEMB_FIXED_OOM_HANDLER oom_handler);

/**
 * @name Memory Management Flags
 */
/*@{*/

/** @brief Non-leave. */
#define FPDFEMB_NONLEAVE		1
/** @brief Movable. */
#define FPDFEMB_MOVABLE			2
/** @brief Discardable. */
#define FPDFEMB_DISCARDABLE		4

/*@}*/

/**
 * @brief Structure: FPDFEMB_MEMMGR_EX
 *			This is an extended version of memory manager interface, allowing advanced
 *			memory management, including movable and discardable memory blocks.
 *
 *			Use this interface with FPDFEMB_InitEx function.
 */
struct FPDFEMB_MEMMGR_EX {
	int		m_Size;			/**< size of the structure. */

	/**
	 * @brief Interface: Alloc
	 *		Allocate a memory block.
	 *
	 * Comments:\n
	 *		The implementation should not do any action if no memory available,
	 *		just return NULL. OOM handling can be done in OOM_Handler interface.
	 *
	 * @param[in] pMgr			Pointer to the memory manager.
	 * @param[in] size			Number of bytes for the memory block.
	 * @param[in] flags			A combination of flags defined above.
	 * @return The pointer to allocated memory block. NULL if no memory available.
	 *		If FPDFEMB_MOVABLE flag is used, implementation should return a handle
	 *		to the memory block, if it supports movable block allocation.
	 */
	void*	(*Alloc)(struct FPDFEMB_MEMMGR_EX* pMgr, unsigned int size, int flags);

	/**
	 * @brief Interface: OOM_Handler
	 *		OOM (out-of-memory) situation handler.
	 *
	 * Comments:\n
	 *		In order to handle OOM situation, application can use longjmp() inside 
	 *		implementation of this function.
	 *
	 * @param[in] pMgr			Pointer to the memory manager.
	 */
	void	(*OOM_Handler)(struct FPDFEMB_MEMMGR_EX* pMgr);

	/**
	 * Interface: Realloc
	 *		Reallocate a memory block
	 *
	 * Comments:\n
	 *		If an existing memory block specified, the data in the memory block should
	 *		be copied to the new block, if reallocated.
	 *
	 *		The implementation should not do any action if no memory available,
	 *		just return NULL. OOM handling can be done in OOM_Handler interface.
	 *
	 * @param[in] pMgr			Pointer to the memory manager.
	 * @param[in] pointer		Pointer to an existing memory block, or handle to a movable
	 *							block. Can not be NULL.
	 * @param[in] new_size		New size (number of bytes) of the memory block. Can not be zero.
	 * @return The pointer of reallocated memory block, it could be a new block, or just
	 *		the previous block with size modified.
	 *		If FPDFEMB_MOVABLE flag is used, implementation should return a handle
	 *		to the memory block, if it supports movable block allocation.
	 */
	void*	(*Realloc)(struct FPDFEMB_MEMMGR_EX* pMgr, void* pointer, unsigned int new_size, int flags);

	/**
	 * @brief Interface: Lock
	 *		Lock a movable memory block
	 * Comments:\n
	 *		This interface is optional, if implementation doesn't support movable memory
	 *		block, then this interface can be set to NULL.
	 * 
	 * @param[in] pMgr			Pointer to the memory manager.
	 * @param[in] handle		Handle to movable memory block, returned by Alloc or Realloc.
	 * @return The pointer of the memory block. NULL if the block was discarded.
	 */
	void*	(*Lock)(struct FPDFEMB_MEMMGR_EX* pMgr, void* handle);

	/**
	 * @brief Interface: Unlock
	 *		Unlock a locked movable memory block.
	 *
	 * Comments:\n
	 *		This interface is optional, if implementation doesn't support movable memory
	 *		block, then this interface can be set to NULL.
	 *
	 * @param[in] pMgr			Pointer to the memory manager.
	 * @param[in] handle		Handle to movable memory block, returned by Alloc or Realloc.
	 */
	void	(*Unlock)(struct FPDFEMB_MEMMGR_EX* pMgr, void* handle);

	/**
	 * @brief Interface: Free
	 *		Free a memory block
	 *
	 * @param[in] pMgr			Pointer to the memory manager.
	 * @param[in] pointer		Pointer to an existing memory block, or handle to a movable block.
	 */
	void	(*Free)(struct FPDFEMB_MEMMGR_EX* pMgr, void* pointer, int flags);

	void*	user;		/**< A user pointer, used by the application. */
};

/**
 * @brief Function: FPDFEMB_InitEx
 *			Initialize the FPDFEMB module with the extended memory manager
 * Comments:\n
 *			This function will allocate necessary internal data structure for
 *			the whole module to operate.
 *
 * @param[in] mem_mgr			Pointer to memory manager structure.
 * @return 	Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_InitEx(struct FPDFEMB_MEMMGR_EX* mem_mgr);

/**
 * @brief Function: FPDFEMB_Exit
 *			Stop using FPDFEMB module and release all resources
 * Comments:\n
 *			All loaded documents and pages will become invalid after this call.
 *
 *			This function is useful for OOM recovery: when your application hits
 *			an OOM situation, calling this function will clear all memory allocated
 *			by FPDFEMB module, then you can call one of the initialization functions,
 *			reopen the document and recovery from OOM.
 */
void FPDFEMB_Exit();

/**
 * @name Enable JBIG2 or JPEG2000 image decoder.
 *
 * Comments:\n
 *			If you want to display JBIG2 or JPEG2000 encoded images, you need to call 
 *			these functions after FPDFEMB initialized.
 *
 *			Calling these functions will increase code size by about 200K-400K bytes.
 *			Also JPEG2000 decoder may not be available on some platforms.
 *
 */
/*@{*/

/** Enable JBIG2 decoder. */
void FPDFEMB_LoadJbig2Decoder();
/** Enable JPEG2000 decoder. */
void FPDFEMB_LoadJpeg2000Decoder();

/*@}*/

/**
 * Function: FPDFEMB_AllocMemory
 *			Allocate memory
 *
 * @param[in] size			Number of bytes
 * @return The allocated buffer pointer. NULL for out of memory.
 */
void* FPDFEMB_AllocMemory(unsigned int size);

/**
 * Function: FPDFEMB_FreeMemory
 *			Free allocated memory
 *
 * @param[in] pointer		Pointer returned by FPDFEMB_AllocMemory
 */
void FPDFEMB_FreeMemory(void* pointer);

/**
 * Function: FPDFEMB_FreeCaches
 *			Free all expendable caches used by FPDFEMB in order to save memory.
 *
 * Comments:\n
 *			When an application memory manager runs out of memory, before an OOM situation 
 *			is raised, the application can try this 
 */
void FPDFEMB_FreeCaches();

/********************************************************************************************
****
****		Document Operations
****
********************************************************************************************/

/**
 * @brief  Structure: FPDFEMB_FILE_ACCESS
 *			Describe the way to access a file (readonly).
 */
struct FPDFEMB_FILE_ACCESS {
	/**
	 * Interface: GetSize
	 *		Get total size of the file
	 *
	 * @param[in] file			Pointer to this file access structure
	 * @return File size, in bytes. Implementation can return 0 for any error.
	 */
	unsigned int	(*GetSize)(struct FPDFEMB_FILE_ACCESS* file);

	/**
	 * Interface: ReadBlock
	 *		Read a data block from the file
	 *
	 * @param[in] file			Pointer to this file access structure
	 * @param[in,out] buffer		Pointer to a buffer receiving read data
	 * @param[in] offset		Byte offset for the block, from beginning of the file
	 * @param[in] size			Number of bytes for the block.
	 * @return Error code, or FPDFERR_SUCCESS for success.
	 */
	FPDFEMB_RESULT	(*ReadBlock)(struct FPDFEMB_FILE_ACCESS* file, void* buffer, 
									unsigned int offset, unsigned int size);

	void*		user;		/**< A user pointer, used by the application. */
};

/**
 * @brief Structure: FPDFEMB_PAUSE
 *			An interface for pausing a progressive process.
 */
struct FPDFEMB_PAUSE {
	/**
	 * Interface: NeedPauseNow
	 *		Check if we need to pause a progressive process now.
	 *
	 * Comments:\n
	 *		Typically implementation of this interface compares the current system tick
	 *		with the previous one, if the time elapsed exceeds certain threshold, then
	 *		the implementation returns TRUE, indicating a pause is needed.
	 *
	 * @param[in] pause			Pointer to the pause structure
	 * @return Non-zero for pause now, 0 for continue.
	 */
	FPDFEMB_BOOL (*NeedPauseNow)(struct FPDFEMB_PAUSE* pause);

	void*		user;		/**< A user pointer, used by the application. */
};

/** @brief PDF document handle type. */
typedef void* FPDFEMB_DOCUMENT;

/**
 * Function: FPDFEMB_StartLoadDocument
 *			Start loading a PDF document
 *
 * Comments:
 *			Document loading is a progressive process. It might take a long time to
 *			load a document, especially when a file is corrupted, FPDFEMB will try to
 *			recover the document contents by scanning the whole file. If "pause" parameter
 *			is provided, this function may return FPDFERR_TOBECONTINUED any time during
 *			the document loading.
 *
 *			When FPDFERR_TOBECONTINUED is returned, the "document" parameter will
 *			still receive a valid document handle, however, no further operations can
 *			be performed on the document, except the "FPDFEMB_ContineLoadDocument" function
 *			call, which resume the document loading.
 *
 * @param[in] file			Pointer to file access structure.
 *							This structure must be kept valid as long as the document is open.
 * @param[in] password		Pointer to a zero-terminated byte string, for the password.
 *							Or NULL for no password.
 * @param[out] document		Receiving the document handle
 * @param[in] pause			A callback mechanism allowing the document loading process
 *							to be paused before it's finished. This can be NULL if you
 *							don't want to pause.
 *
 * @retval FPDFERR_SUCCESS				document successfully loaded.
 * @retval FPDFERR_TOBECONTINUED		The document loading can't be finished now.
 *										See comments below.
 * @retval FPDFERR_PASSWORD				incorrect password.
 * @retval FPDFERR_FORMAT				not a PDF or corrupted PDF.
 * @retval FPDFERR_FILE					file access error.
 * @retval FPDFERR_MEMORY				out of memory.
 */
FPDFEMB_RESULT FPDFEMB_StartLoadDocument(struct FPDFEMB_FILE_ACCESS* file, const char* password, 
									FPDFEMB_DOCUMENT* document, struct FPDFEMB_PAUSE* pause);

/**
 * @brief Function: FPDFEMB_ContinueLoadDocument
 *			Continue loading a PDF document
 *
 * @param[in] document		Document handle returned by FPDFEMB_StartLoadDocument function
 * @param[in] pause			A callback mechanism allowing the document loading process
 *							to be paused before it's finished. This can be NULL if you
 *							don't want to pause.
 *
 * @retval FPDFERR_SUCCESS				document successfully loaded.
 * @retval FPDFERR_TOBECONTINUED		The document loading can't be finished now.
 *										Further call to this function is needed.
 * @retval FPDFERR_PASSWORD				incorrect password.
 * @retval FPDFERR_FORMAT				not a PDF or corrupted PDF.
 * @retval FPDFERR_FILE					file access error.
 * @retval FPDFERR_MEMORY				out of memory.
 * @retval FPDFERR_STATUS				document already loaded.
 * @retval FPDFERR_PARAM				invalid parameter (like NULL document handle)
 */
FPDFEMB_RESULT FPDFEMB_ContinueLoadDocument(FPDFEMB_DOCUMENT document, struct FPDFEMB_PAUSE* pause);

/**
 * Function: FPDFEMB_CloseDocument
 *			Close a PDF document and free all associated resources
 *
 * @param[in] document			Document handle
 * @return Error code. FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_CloseDocument(FPDFEMB_DOCUMENT document);

/**
 * Function: Get page count
 *			Get number of pages in the document
 * 
 * @param[in] document			Document handle
 * @return Number of pages.
 */
int FPDFEMB_GetPageCount(FPDFEMB_DOCUMENT document);

/**
 * Function: FPDFEMB_SetFileBufferSize
 *			Set size of internal buffer used to read from source file.
 *
 * Comments:\n
 *			Currently FPDFEMB uses 512 bytes as default buffer size. The new buffer size 
 *			takes effect next time you call FPDFEMB_StartLoadDocument.
 *
 * @param[in] size				Number of bytes.
 */
void FPDFEMB_SetFileBufferSize(int size);

/********************************************************************************************
****
****		Page Basic Operations
****
********************************************************************************************/

/** @brief PDF page handle type. */
typedef void* FPDFEMB_PAGE;

/**
 * Function: FPDFEMB_LoadPage
 *			Load a page
 *
 * @param[in] document		Document handle
 * @param[in] index			Page index, starting from zero
 * @param[out] page			Receiving the loaded page handler
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_LoadPage(FPDFEMB_DOCUMENT document, int index, FPDFEMB_PAGE* page);

/**
 * Function: FPDFEMB_ClosePage
 *			Close a page and release all related resources
 *
 * @param[in] page			Page handle
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_ClosePage(FPDFEMB_PAGE page);

/**
 * Function: EstimatePageComplexity
 *			Get complexity estimate before parsing page to help decide how
 *          to handle page operations
 * Comments:\n
 *          Size of page content stream returned by this function
 *          may not accurately reflect page complexity because page content
 *          stream may inline content which artificially inflate the size
 *
 * @param[in]     page			Page handle
 * @param[in,out] size			Receiving size of page content stream
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_EstimatePageComplexity(FPDFEMB_PAGE page, int* size);

/**
 * Function: FPDFEMB_GetPageSize
 *			Get size of a page
 *
 * @param[in] page			Page handle
 * @param[out] width		Receiving page width, in hundredth of points
 * @param[out] height		Receiving page height, in hundredth of points
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_GetPageSize(FPDFEMB_PAGE page, int* width, int* height);

/**
 * @brief Structure: FPDFEMB_RECT
 *			Rectangle area in device or page coordination system
 */
struct FPDFEMB_RECT
{
	/**
	 * @name For device system, coordinations are measured in pixels;
	 * For page system, coordinations are measured in hundredth of points.
	/*@{*/

	/** The x-coordinate of the left-top corner. */
	int		left;
	/** the y-coordinate of the left-top corner. */
	int		top;
	/** The x-coordinate of the right-bottom corner. */
	int		right;
	/** The y-coordinate of the right-bottom corner. */
	int		bottom;

	/*@}*/
};

/**
 * Function: FPDFEMB_GetPageBBox
 *			Get displayable area (bounding box) of a page
 *
 * @param[in] page			Page handle
 * @param[out] rect			Pointer to a structure receiving the rectangle
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_GetPageBBox(FPDFEMB_PAGE page, struct FPDFEMB_RECT* rect);

/********************************************************************************************
****
****		Page Parsing
****
********************************************************************************************/

/**
 * Function: FPDFEMB_StartParse
 *			Start parsing a page, so it can get rendered or searched.
 *
 * Comments:\n
 *			Parsing is a progressive process. This function starts the parsing process,
 *			and may return before parsing is finished, if a pause structure is provided.
 *
 *			Application should call FPDFEMB_ContinueParse repeatedly to finish the parsing
 *			when return value is FPDFERR_TOBECONTINUED.
 *
 *			There can be only one parsing procedure active for a page, and if a page
 *			has already been parsed, you can't start a parsing again.
 *
 * @param[in] page			Page handle
 * @param[in] text_only		flag for parsing texts only (used for searching)
 * @param[in] pause			A structure that can pause the parsing process.
 *							Or NULL if you don't want to pause the process.
 *
 * @retval FPDFERR_SUCCESS			parsing successfully finished;
 * @retval FPDFERR_TOBECONTINUED	parsing started successfully, but not finished;
 * @retval FPDFERR_STATUS			page already parsed, or parsing already started. 
 *			Other return value: error code.
 */
FPDFEMB_RESULT FPDFEMB_StartParse(FPDFEMB_PAGE page, FPDFEMB_BOOL text_only, 
												struct FPDFEMB_PAUSE* pause);

/**
 * Function: FPDFEMB_ContinueParse
 *			Continue the page parsing.
 *
 * Comments:\n
 *			FPDFEMB_StartParse should be called before on the page.
 *
 *			Application should call FPDFEMB_ContinueParse repeatedly to finish the parsing
 *			when return value is FPDFERR_TOBECONTINUED.
 *
 * @param[in] page			Page handle
 * @param[in] pause			A structure that can pause the parsing process.
 *							Or NULL if you don't want to pause the process.
 *
 * @retval FPDFERR_SUCCESS			parsing successfully finished;
 * @retval FPDFERR_TOBECONTINUED	parsing performed successfully, but not finished;
 * @retval FPDFERR_STATUS			page already parsed (or parsing not started). 
 * @retval Other return value		error code.
 */
FPDFEMB_RESULT FPDFEMB_ContinueParse(FPDFEMB_PAGE page, struct FPDFEMB_PAUSE* pause);

/**
 * Function: FPDFEMB_GetParseProgress
 *			Get an estimated parsing progress in percentage
 *
 * @param[in] page			Page handle
 * @return  An integer between 0 and 100 (inclusive) indicating the parsing progress.
 *			The result is just a rough estimation.
 */
int FPDFEMB_GetParseProgress(FPDFEMB_PAGE page);

/********************************************************************************************
****
****		Page Rendering
****
********************************************************************************************/

/** @brief Bitmap handle type. */
typedef void* FPDFEMB_BITMAP;

/**
 * Function: FPDFEMB_StartQuickDraw
 *			Start drawing a quick preview of a page
 * Comments:
 *			It's often useful to present user a quick preview of a page, right after the
 *			page is parsed. This preview renders only a limited set of easy features in the
 *			page, so it'll be rather quick to finish this process.
 *
 * @param[in] dib			DIB handle, as the rendering device
 * @param[in] page			Page handle. The page has to be parsed first.
 * @param[in] start_x		Left pixel position of the display area in the device coordination
 * @param[in] start_y		Top pixel position of the display area in the device coordination
 * @param[in] size_x		Horizontal size (in pixels) for displaying the page
 * @param[in] size_y		Vertical size (in pixels) for displaying the page
 * @param[in] rotate		Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
 *								2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
 * @param[in] flags			Reserved, must be zero.
 * @param[in] pause			Pointer to a structure that can pause the rendering process.
 *							Can be NULL if no pausing is needed.
 *
 * @retval FPDFERR_SUCCESS				quickdraw successfully finished;
 * @retval FPDFERR_TOBECONTINUED		quickdraw started successfully, but not finished.
 * @retval FPDFEMB_ContinueQuickDraw	needs to be called to finish the quickdraw;
 * @retval FPDFERR_STATUS				quickdraw already in progress, or page not parsed;
 * @retval Other return value: error code.
 */
FPDFEMB_RESULT FPDFEMB_StartQuickDraw(FPDFEMB_BITMAP dib, FPDFEMB_PAGE page,
							int start_x, int start_y, int size_x, int size_y, int rotate,
							int flags, struct FPDFEMB_PAUSE* pause);

/**
 * Function: FPDFEMB_ContinueQuickDraw
 *			Continue a quick draw processing
 *
 * @param[in] page			Page handle. The page has to be parsed first.
 * @param[in] pause			Pointer to a structure that can pause the rendering process.
 *							Can be NULL if no pausing is needed.
 *
 * @retval FPDFERR_SUCCESS			quickdraw successly finished;
 * @retval FPDFERR_TOBECONTINUED	quickdraw started successfully, but not finished.
 * 									more calls to this function needed to finish the quickdraw;
 * @retval FPDFERR_STATUS			quickdraw not started yet; 
 * @retval Other return value		error code.
 */
FPDFEMB_RESULT FPDFEMB_ContinueQuickDraw(FPDFEMB_PAGE page, struct FPDFEMB_PAUSE* pause);

/**
 * @name Render flags.
 */
/*@{*/

/** @brief Set if annotations are to be rendered. */
#define FPDFEMB_ANNOT			0x01
/** @brief Set if using text rendering optimized for LCD display. */
#define FPDFEMB_LCD_TEXT		0x02
/** @brief Set if the device is using BGR LCD stripe. */
#define FPDFEMB_BGR_STRIPE		0x04
/** @brief Drop the page objects that are rendered. This will make the most complicated pages renderable
	within very limited memory. HOWEVER, after rendering the page will not be useable anymore! You will
	have to close the page and start it over! */
#define FPDFEMB_DROP_OBJECTS	0x08
/** @brief Always use anti-aliasing for rectangle drawing. */
#define FPDFEMB_USEAA			0x80
/*@}*/ 

/**
 * Function: FPDFEMB_StartRender
 *			Start rendering of a page.
 *
 * Comments:\n
 *			Rendering is a progressive process. This function starts the rendering process,
 *			and may return before rendering is finished, if a pause structure is provided.
 *
 *			Application should call FPDFEMB_ContinueRender repeatedly to finish the rendering 
 *			when return value is FPDFERR_TOBECONTINUED.
 *
 *			There can be only one rendering procedure for a page at any time. And rendering
 *			can be started over and over again for the same page. If a page rendering is already
 *			active, starting another one will cancel the previous rendering.
 *
 *			Rendering of a page doesn't draw the page background, therefore, you usually need
 *			to draw the background in the DIB yourself.
 *
 *			You don't have to parse the page before you can render it. The engine will parse
 *			the page along with the rendering process. With this technique, along with
 *			FPDFEMB_DROP_OBJECTS flag, you can really render very complicated pages without
 *			much memory consumption (because no page objects will be cached).
 *
 * @param[out] dib			DIB handle, as the rendering device
 * @param[in] page			Page handle. The page has to be parsed first.
 * @param[in] start_x		Left pixel position of the display area in the device coordination
 * @param[in] start_y		Top pixel position of the display area in the device coordination
 * @param[in] size_x		Horizontal size (in pixels) for displaying the page
 * @param[in] size_y		Vertical size (in pixels) for displaying the page
 * @param[in] rotate		Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
 *								2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
 * @param[in] flags			0 for normal display, or combination of flags defined above
 * @param[in] clip			Pointer to clip rectangle (in DIB device coordinations),
 *							or NULL if no clipping needed.
 * @param[in] pause			Pointer to a structure that can pause the rendering process.
 * 							Can be NULL if no pausing is needed.
 *
 * @retval FPDFERR_SUCCESS			rendering successfully finished;
 * @retval FPDFERR_TOBECONTINUED	rendering started successfully, but not finished;
 * @retval Other return value		error code.
 */
FPDFEMB_RESULT FPDFEMB_StartRender(FPDFEMB_BITMAP dib, FPDFEMB_PAGE page,
						int start_x, int start_y, int size_x, int size_y, int rotate, int flags,
						struct FPDFEMB_RECT* clip, struct FPDFEMB_PAUSE* pause);

/**
 * Function: FPDFEMB_ContinueRender
 *			Continue the page rendering
 *
 * Comments:\n
 *			This function may return any time when the pause interface indicates 
 *			a pause is needed. Application can call FPDFEMB_ContinueRender any number
 *			of times, until FPDFERR_TOBECONTINUED is not returned.
 *
 * @param[in] page			Page handle
 * @param[in] pause			Pointer to a structure that can pause the rendering process.
 *							Can be NULL if no pausing is needed.
 *
 * @retval FPDFERR_SUCCESS			rendering successfully finished.
 * @retval FPDFERR_TOBECONTINUED	rendering needs to be continued;
 * @retval Other return value		error code.
 */
FPDFEMB_RESULT FPDFEMB_ContinueRender(FPDFEMB_PAGE page, struct FPDFEMB_PAUSE* pause);

/**
 * Function: FPDFEMB_GetRenderProgress
 *			Get an estimated rendering progress in percentage
 *
 * @param[in] page					Page handle
 * @return	An integer between 0 and 100 (inclusive) indicating the rendering progress.
 *			The result is just a rough estimation.
 *			If the rendering just finished, this function will return 0.
 */
int FPDFEMB_GetRenderProgress(FPDFEMB_PAGE page);

/**
 * Function: FPDFEMB_CancelRender
 *			Cancel the page rendering.
 *
 * @param[in] page					Page handle
 * @retval FPDFERR_SUCCESS			rendering successfully canceled.
 * @retval Other return value		error code.
 */
FPDFEMB_RESULT FPDFEMB_CancelRender(FPDFEMB_PAGE page);

/**
 * Function: FPDFEMB_SetHalftoneLimit
 *			Set pixel count limit for using halftone when display image
 *
 * Comments:\n
 *			By default, FPDFEMB displays all bitmaps using downsamping, which means
 *			if the image is shrinked onto screen, only part of pixels will be picked
 *			and displayed. This saves a lot of calculation, especially for big images
 *			with millions of pixels. However the display quality can be bad. In order to
 *			reach a balance between performance and quality, application can use this
 *			function to set a limit, if number of pixels in an image is more than this
 *			limit, then FPDFEMB will use downsampling for quick drawing, otherwise, if
 *			the image has less pixels, FPDFEMB will use halftoning for better quality.
 *
 * @param[in] limit			Number of pixels for the limit
 */
void FPDFEMB_SetHalftoneLimit(int limit);
/**
 * Function: FPDFEMB_SetRenderStepLimit
 *			Set objects step for progressive render or quick draw. 
 *
 * Comments:\n
 *			Used parsing is a progressive process, set objects step for progressive render.
 *			By default, this value is 20 for mini, 100 for non-mini, indicating that 
 *			we ask FPDFEMB_PAUSE whether to need to pause after progressing 20 objects.
 *
 * @param[in] limit		Step limit.
 */
void FPDFEMB_SetRenderStepLimit(int limit);

/********************************************************************************************
****
****		Coordination Conversion
****
********************************************************************************************/

/**
 * @brief Structure: FPDFEMB_POINT
 *			A point in device or page coordination system
 */
struct FPDFEMB_POINT
{
	/**
	 * @name For device system, coordinations are measured in pixels;
	 * For page system, coordinations are measured in hundredth of points.
	/*@{*/

	/** The x-coordinate. */
	int		x;
	/** The y-coordinate. */
	int		y;

	/*@}*/
};

/**
 * @brief Structure: FPDFEMB_POINTF
 *			A point in device or page coordination system
 */
struct FPDFEMB_POINTF
{
	/**
	 * @name For device system, coordinations are measured in pixels;
	 * For page system, coordinations are measured in hundredth of points.
	/*@{*/

	/** The x-coordinate. */
	float	x;
	/** The y-coordinate. */
	float	y;

	/*@}*/
};

/**
 * @brief Structure: FPDFEMB_RECTF
 *			Rectangle area in device or page coordination system
 */
struct FPDFEMB_RECTF
{
	/**
	 * @name For device system, coordinations are measured in pixels;
	 * For page system, coordinations are measured in hundredth of points.
	/*@{*/

	/** The x-coordinate of the left-top corner. */
	float	left;
	/** the y-coordinate of the left-top corner. */
	float	top;
	/** The x-coordinate of the right-bottom corner. */
	float	right;
	/** The y-coordinate of the right-bottom corner. */
	float	bottom;

	/*@}*/
};

/**
 * Function: FPDFEMB_DeviceToPagePoint, FPDFEMB_DeviceToPageRect
 *			Convert the device coordinations of a point or a rectangle to page coordinations.
 *
 * Comments:\n
 *			The page coordination system has its origin at left-bottom corner of the page, 
 *			with X axis goes along the bottom side to the right, and Y axis goes along the 
 *			left side upward. No matter how you zoom, scroll, or rotate a page, a particular
 *			element (like text or image) on the page should always have the same coordination 
 *			values in the page coordination system. 
 *
 *			The device coordination system is device dependent. For bitmap device, its origin 
 *			is at left-top corner of the window. You must make sure the start_x, start_y, size_x, 
 *			size_y and rotate parameters have exactly same values as you used in 
 *			FPDFEMB_StartRender() function call.
 *
 *			For rectangle conversion, the result rectangle is always "normalized", meaning for
 *			page coordinations, left is always smaller than right, bottom is smaller than top.
 *
 * @param[in] page			Handle to the page. Returned by FPDFEMB_LoadPage function.
 * @param[in] start_x		Left pixel position of the display area in the device coordination
 * @param[in] start_y		Top pixel position of the display area in the device coordination
 * @param[in] size_x		Horizontal size (in pixels) for displaying the page
 * @param[in] size_y		Vertical size (in pixels) for displaying the page
 * @param[in] rotate		Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
 *								2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
 * @param[in,out] point		A point structure with device coordinations upon the call,
 *							also receiving the result page coordinations.
 */
void FPDFEMB_DeviceToPagePoint(FPDFEMB_PAGE page, 
						int start_x, int start_y, int size_x, int size_y, int rotate, 
						struct FPDFEMB_POINT* point);

/**
 * Function: FPDFEMB_DeviceToPagePointF, FPDFEMB_DeviceToPageRectF
 *			Convert the device coordinations of a point or a rectangle to page coordinations.
 *			See the above FPDFEMB_DeviceToPagePoint definitions.
 */
void FPDFEMB_DeviceToPagePointF(FPDFEMB_PAGE page, 
						int start_x, int start_y, int size_x, int size_y, int rotate, 
						struct FPDFEMB_POINTF* point);

/**
 * @see FPDFEMB_DeviceToPagePoint() 
 *
 * @param[in] page			Handle to the page. Returned by FPDFEMB_LoadPage function.
 * @param[in] start_x		Left pixel position of the display area in the device coordination
 * @param[in] start_y		Top pixel position of the display area in the device coordination
 * @param[in] size_x		Horizontal size (in pixels) for displaying the page
 * @param[in] size_y		Vertical size (in pixels) for displaying the page
 * @param[in] rotate		Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
 *								2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
 * @param[in,out] rect		A rectangle structure with device coordinations upon the call,
 *							also receiving the result page coordinations.
 */
void FPDFEMB_DeviceToPageRect(FPDFEMB_PAGE page, 
						int start_x, int start_y, int size_x, int size_y, int rotate, 
						struct FPDFEMB_RECT* rect);

/**
 * Function: FPDFEMB_DeviceToPagePointF, FPDFEMB_DeviceToPageRectF
 *			Convert the device coordinations of a point or a rectangle to page coordinations.
 *			See the above FPDFEMB_DeviceToPagePoint definitions.
 */
void FPDFEMB_DeviceToPageRectF(FPDFEMB_PAGE page, 
						int start_x, int start_y, int size_x, int size_y, int rotate, 
						struct FPDFEMB_RECTF* rect);

/**
 * Function: FPDFEMB_PageToDevicePoint, FPDFEMB_PageToDeviceRect
 *			Convert the page coordinations of a point or a rectangle to device coordinations.
 *
 * Comments:\n
 *			For rectangle conversion, the result rectangle is always "normalized", meaning for
 *			device coordinations, left is always smaller than right, top is smaller than bottom.
 *
 * @param[in] page			Handle to the page. Returned by FPDFEMB_LoadPage function.
 * @param[in] start_x		Left pixel position of the display area in the device coordination
 * @param[in] start_y		Top pixel position of the display area in the device coordination
 * @param[in] size_x		Horizontal size (in pixels) for displaying the page
 * @param[in] size_y		Vertical size (in pixels) for displaying the page
 * @param[in] rotate		Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
 * 								2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
 * @param[in,out] point		A point structure with page coordinations upon the call,
 *							also receiving the result device coordinations.
 */
void FPDFEMB_PageToDevicePoint(FPDFEMB_PAGE page, 
						int start_x, int start_y, int size_x, int size_y, int rotate, 
						struct FPDFEMB_POINT* point);

/**
 * Function: FPDFEMB_PageToDevicePointF, FPDFEMB_PageToDeviceRectF
 *			Convert the page coordinations of a point or a rectangle to device coordinations.
 *			See the above FPDFEMB_PageToDevicePoint definitions.
 */
void FPDFEMB_PageToDevicePointF(FPDFEMB_PAGE page, 
						int start_x, int start_y, int size_x, int size_y, int rotate, 
						struct FPDFEMB_POINTF* point);

/**
 * @see FPDFEMB_PageToDevicePoint()
 *
 * @param[in] page			Handle to the page. Returned by FPDFEMB_LoadPage function.
 * @param[in] start_x		Left pixel position of the display area in the device coordination
 * @param[in] start_y		Top pixel position of the display area in the device coordination
 * @param[in] size_x		Horizontal size (in pixels) for displaying the page
 * @param[in] size_y		Vertical size (in pixels) for displaying the page
 * @param[in] rotate		Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
 * 								2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
 * @param[in,out] rect		A rectangle structure with page coordinations upon the call,
 *							also receiving the result device coordinations.
 */
void FPDFEMB_PageToDeviceRect(FPDFEMB_PAGE page, 
						int start_x, int start_y, int size_x, int size_y, int rotate, 
						struct FPDFEMB_RECT* rect);

/**
 * Function: FPDFEMB_PageToDevicePointF, FPDFEMB_PageToDeviceRectF
 *			Convert the page coordinations of a point or a rectangle to device coordinations.
 *			See the above FPDFEMB_PageToDevicePoint definitions.
 */
void FPDFEMB_PageToDeviceRectF(FPDFEMB_PAGE page, 
						int start_x, int start_y, int size_x, int size_y, int rotate, 
						struct FPDFEMB_RECTF* rect);

/********************************************************************************************
****
****		Text Search
****
********************************************************************************************/

/**
 * @name Search flags for FPDFEMB_FindFirst function.
 */
/*@{*/

/** @brief whether matching case. */
#define FPDFEMB_MATCHCASE		1
/** @brief whether matching whole word. */
#define FPDFEMB_MATCHWHOLEWORD	2
/** whether matching consecutively (for example, "CC" will match twice in "CCC"). */
#define FPDFEMB_CONSECUTIVE		4

/*@}*/

/**
 * Function: FPDFEMB_FindFirst
 *			Find first occurrence of a pattern string in a page
 *
 * Comments:\n
 *			A page must be parsed first before it can be searched.
 *			There can be only one search in progress for a page. A new search will 
 *			cancel the previous one.
 *
 *			IMPORTANT: this function is now obsolete and kept for back compatibility
 *			only, please use FPDFEMB_FindFrom function below.
 *
 * @param[in] page			Page handle.
 * @param[in] pattern		A zero-terminated unicode string to be found. 
 * @param[in] from_last		Whether we start from the end of page
 * @param[in] flags			Search flags, see above defined constants
 * @return  Error code, or FPDFERR_SUCCESS for success.
 *			Is not found, FPDFERR_NOTFOUND is returned.
 */
FPDFEMB_RESULT FPDFEMB_FindFirst(FPDFEMB_PAGE page, const FPDFEMB_WCHAR* pattern, 
								 FPDFEMB_BOOL from_last, unsigned int flags);

/**
 * Function: FPDFEMB_FindFrom
 *			Find first occurrence of a pattern string in a page, from a particular position
 *
 * Comments:
 *			A page must be parsed first before it can be searched.
 *			There can be only one search in progress for a page. A new search will 
 *			cancel the previous one.
 *
 * @param[in] page			Page handle.
 * @param[in] pattern		A zero-terminated unicode string to be found. 
 * @param[in] pos			The position, returned from FPDFEMB_GetSearchPos.
 *							Or 0 from the beginning of page, -1 from the end of page.
 * @param[in] flags			Search flags, see above defined constants
 * @return  Error code, or FPDFERR_SUCCESS for success.
 *			Is not found, FPDFERR_NOTFOUND is returned.
 */
FPDFEMB_RESULT FPDFEMB_FindFrom(FPDFEMB_PAGE page, const FPDFEMB_WCHAR* pattern, 
								 int pos, unsigned int flags);

/**
 * Function: FPDFEMB_FindNext
 *			Find next occurrence of a search
 *
 * @param[in] page			Page handle. 
 *							FPDFEMB_FindFirst must be called for this page first.
 * @return	Error code, or FPDFERR_SUCCESS for success.
 *			Is not found, FPDFERR_NOTFOUND is returned.
 */
FPDFEMB_RESULT FPDFEMB_FindNext(FPDFEMB_PAGE page);

/**
 * Function: FPDFEMB_FindPrev
 *			Find previous occurrence of a search
 *
 * @param[in] page			Page handle.
 *							FPDFEMB_FindFirst must be called for this page first.
 * @return	Error code, or FPDFERR_SUCCESS for success.
 *			Is not found, FPDFERR_NOTFOUND is returned.
 */
FPDFEMB_RESULT FPDFEMB_FindPrev(FPDFEMB_PAGE page);

/**
 * Function: FPDFEMB_CountFoundRects
 *			Get number of rectangles for last found result
 *
 * @param[in] page			Page handle.
 * @return Number of rectangles for last found result. 0 for not found or failure.
 */
int FPDFEMB_CountFoundRects(FPDFEMB_PAGE page);

/**
 * Function: FPDFEMB_GetFoundRect
 *			Get a particular found rectangle
 *
 * Comments:
 *			Application should always call FPDFEMB_CountFoundRects first to get
 *			number of rectangles, then use this function to get each rectangle.
 *
 *			The returned rectangle uses page coordination system.
 *
 * @param[in] page			Page handle.
 * @param[in] index			Zero-based index for the rectangle.
 * @param[out] rect			Receiving the result rectangle, in hundredth of points
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_GetFoundRect(FPDFEMB_PAGE page, int index, struct FPDFEMB_RECT* rect);

/**
 * Function: FPDFEMB_GetSearchPos
 *			Return position of current search result
 *
 * @param[in] page			Page handle.
 * @return Zero based character index for the current search result. -1 if not found.
 */
int FPDFEMB_GetSearchPos(FPDFEMB_PAGE page);

/**
 * Function: FPDFEMB_QuickSearch
 *			Search a pattern in a page quickly, without the page to be parsed
 *
 * Comments:
 *			This function does a rough and quick search in a page, before the page is loaded. 
 *			The quick search will not generate an exact result saying where the pattern is
 *			found, and, it might be possible if a quick search result is "pattern found", and
 *			a real search for the same pattern, in the same page, will result in "not found".
 *
 *			However, if quick search doesn't find a pattern in a page, then we can be sure the
 *			pattern won't be found in this page when we do a real search. So, this function is 
 *			very useful when we search in a multiple-page document, and we want to quickly skip
 *			those pages in which the pattern can't possibly be found.
 *
 * @param[in] document			Document handle returned by FPDFEMB_StartLoadDocument function
 * @param[in] page_index		Zero-based index of the page
 * @param[in] pattern			A zero-terminated unicode string to be found. 
 * @param[in] case_sensitive	Non-zero for case-sensitive searching, zero for case-insensitive
 * @return 	FPDFERR_SUCCESS if pattern found, FPDFERR_NOTFOUND if pattern not found.
 *			Otherwise error code is returned.
 */
FPDFEMB_RESULT FPDFEMB_QuickSearch(FPDFEMB_DOCUMENT document, int page_index, 
								   const FPDFEMB_WCHAR* pattern, int case_sensitive);

/********************************************************************************************
****
****		Text Information
****
********************************************************************************************/

/**
 * Function: FPDFEMB_GetCharCount
 *			Get number of characters in the page
 *
 * @param[in] page			Page handle
 * @param[out] count		Receiving number of characters
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_GetCharCount(FPDFEMB_PAGE page, int* count);

/**
 * @brief Structure: FPDFEMB_CHAR_INFO
 *			Character information.
 */
struct FPDFEMB_CHAR_INFO {
	/**
	 * Unicode for the character. 0 if not available.
	 * Space and new line characters (U+0020 and U+000A) may be generated
	 * according to the text formatting.
	 */
	int		unicode;
	/** X/Y position for the character origin, in hundredth of points. */
	struct FPDFEMB_POINT	origin;
	/**
	 * Bounding box of the character, in hundredth of points
	 * Maybe an empty box (left == right or top == bottom).
	 */
	struct FPDFEMB_RECT	bbox;
};

/**
 * Function: FPDFEMB_GetCharInfo
 *			Get character information
 *
 * Comments:
 *			Application must call FPDFEMB_GetCharCount first before it can call this function
 *			for any particular characters.
 *
 * @param[in] page			Page handle
 * @param[in] index			Character index, starting from zero
 * @param[out] char_info	Receiving the character info
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_GetCharInfo(FPDFEMB_PAGE page, int index, struct FPDFEMB_CHAR_INFO* char_info);

/**
 * Function: FPDFEMB_GetCharIndexAtPos()
 *			Get index of character nearest to a certain position on the page
 *
 * Comments:
 *			This function finds the character that's nearest to the particular page position.
 *			If there is no character, the output index will be -1.
 *
 * @param[in] page			Page handle
 * @param[in] x				X position in PDF page coordination system
 * @param[in] y				Y position in PDF page coordination system
 * @param[in] index			Pointer to an integer receiving zero-based character index.
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_GetCharIndexAtPos(FPDFEMB_PAGE page, double x, double y, int* index);

/********************************************************************************************
****
****		Device Independent Bitmap
****
********************************************************************************************/

/**
 * @name DIB format.
 */
/*@{*/

/** @brief 3 bytes per pixel, byte order: Blue, Green, Red. */
#define FPDFDIB_BGR		1
/** @brief 4 bytes per pixel, byte order: Blue, Green, Red, not used. */
#define FPDFDIB_BGRx	2
/** @brief 4 bytes per pixel, byte order: Blue, Green, Red, Alpha. */
#define FPDFDIB_BGRA	3
/** @brief 1 byte per pixel (grayscale). */
#define FPDFDIB_GRAY	4
/** @brief 3 bytes per pixel, byte order: Red, Green, Blue. */
#define FPDFDIB_RGB		5
/** @brief 4 bytes per pixel, byte order: Red, Green, Blue, not used. */
#define FPDFDIB_RGBx	6
/** @brief 4 bytes per pixel, byte order: Red, Green, Blue, Alpha. */
#define FPDFDIB_RGBA	7
/** @brief 2 bytes per pixel, byte order: Red 5 bits, Green 6 bits, Blue 5 bits. If this format available, other DIB formats will not be used. */
#define FPDFDIB_RGB565	8

/*@}*/

/**
 * Function: FPDFEMB_CreateDIB
 *			Create a DIB (Device Independent Bitmap)
 *
 * Comments:
 *			If "buffer" parameter is not NULL, then the provided buffer must conform
 *			to standard DIB format (see comments of FPDFEMB_GetDIBData function below).
 *
 *			This function doesn't initialize the pixels inside the DIB buffer. So if you
 *			want to use the DIB to display a PDF page, you usually need to initialize
 *			the DIB to white background by youself.
 *
 * @param[in] width			Width pixels;
 * @param[in] height		Height pixels;
 * @param[in] format		Format type. See FPDFDIB_xxx constants
 * @param[in] buffer		External buffer provided for the DIB,
 *							or NULL if new buffer is to be allocated.
 * @param[in] stride		Number of bytes for each scan line, for external buffer only.
 *							If not specified, 4-byte alignment assumed.
 * @param[out] dib			Receiving the created DIB handle
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_CreateDIB(int width, int height, int format, 
									   void* buffer, int stride, FPDFEMB_BITMAP* dib);

/**
 * Function: FPDFEMB_DestroyDIB
 *			Destroy a DIB
 *
 * Comments:
 *			If external buffer is used (specified in "buffer" parameter when calling
 *			FPDFEMB_CreateDIB), the buffer will not be destroyed.
 *
 * @param[in] dib			DIB handle
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_DestroyDIB(FPDFEMB_BITMAP dib);

/**
 * Function: FPDFEMB_GetDIBWidth
 *			Get width (in pixels) of a DIB
 *
 * @param[in] dib				DIB handle
 * @return DIB width in pixels.
 */
int FPDFEMB_GetDIBWidth(FPDFEMB_BITMAP dib);

/**
 * Function: FPDFEMB_GetDIBHeight
 *			Get height (in pixels) of a DIB
 *
 * @param[in] dib				DIB handle
 * @return DIB height in pixels.
 */
int FPDFEMB_GetDIBHeight(FPDFEMB_BITMAP dib);

/**
 * Function: FPDFEMB_GetDIBData
 *			Get data pointer to a DIB
 *
 * Comments:
 *			DIB data are organized in scanlines, from top down.
 *
 * @param[in] dib				DIB handle
 * @return Pointer to the DIB data.
 */
void* FPDFEMB_GetDIBData(FPDFEMB_BITMAP dib);

/**
 * Function: FPDFEMB_GetDIBStride
 *			Get scan line stride of a DIB
 *
 * @param[in] dib				DIB handle
 * @return Number of bytes occupied by a scanline
 */
int FPDFEMB_GetDIBStride(FPDFEMB_BITMAP dib);

/**
 * Function: FPDFEMB_GetRotatedDIB
 *			Swap X/Y dimensions of a DIB to generate a rotated new DIB
 *
 * @param[in] dib			DIB handle
 * @param[in] bFlipX		Whether flip pixels on the destination X dimension (left/right)
 * @param[in] bFlipY		Whether flip pixels on the destination Y dimension (up/down)
 * @param[out] result_dib	Receiving the result DIB handle
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_GetRotatedDIB(FPDFEMB_BITMAP dib, 
									 FPDFEMB_BOOL bFlipX, FPDFEMB_BOOL bFlipY,
									 FPDFEMB_BITMAP* result_dib);

/**
 * Function: FPDFEMB_StretchDIB
 *			Stretch a source DIB into another destination DIB
 *
 * @param[out] dest_dib		The destination DIB handle
 * @param[in] dest_left		Left position in the destination DIB
 * @param[in] dest_top		Top position in the destination DIB
 * @param[in] dest_width	Destination width, in pixels. Can be negative for horizontal flipping
 * @param[in] dest_height	Destination height, in pixels. Can be negative for vertical flipping
 * @param[in] clip_rect		Destination clipping rectangle, or NULL for no clipping.
 *							The coordinations are measured in destination bitmap.
 * @param[in] src_dib		Source DIB handle.
 * @param[in] interpol		Whether we use interpolation to improve the result quality
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_StretchDIB(FPDFEMB_BITMAP dest_dib, int dest_left, int dest_top,
								  int dest_width, int dest_height, struct FPDFEMB_RECT* clip_rect, 
								  FPDFEMB_BITMAP src_dib, FPDFEMB_BOOL interpol);

/**
 * Function: FPDFEMB_TransformDIB
 *			Transform a source DIB into another destination DIB
 *
 * Comments:
 *			All coordinations and distances are measured in destination bitmap system.
 *
 *			This function places the bottom-left pixel of the image at the destination
 *			origin, then the bottom sideline along the destination X vector, and left 
 *			sideline along the destination Y vector.
 *
 * @param[out] dest_dib		The destination DIB handle
 * @param[in] clip_rect		Destination clipping rectangle, or NULL for no clipping.
 * 							The coordinations are measured in destination bitmap.
 * @param[in] src_dib		Source DIB handle.
 * @param[in] x				X coordination of the dest origin
 * @param[in] y				Y coordination of the dest origin
 * @param[in] xx			X distance of the dest X vector
 * @param[in] yx			Y distance of the dest X vector
 * @param[in] xy			X distance of the dest Y vector
 * @param[in] yy			Y distance of the dest Y vector
 * @param[in] interpol		Whether we use interpolation to improve the result quality
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_TransformDIB(FPDFEMB_BITMAP dest_dib, struct FPDFEMB_RECT* clip_rect, 
								  FPDFEMB_BITMAP src_dib, int x, int y, int xx, int yx,
								  int xy, int yy, FPDFEMB_BOOL interpol);

/********************************************************************************************
****
****		Custom Font Handler and CJK Support
****
********************************************************************************************/

// FPDFEMB comes with standard fonts for Latin characters. If your device is targeted to
// Eastern Asian markets, then system fonts must be provided and registered with FPDFEMB.
// Depending on your device configuration, those system fonts might be in TrueType or Type1
// format, or some other non-standard compact format. For the first case, you should register
// a font mapper so FPDFEMB can pick the right font file, and for the second case, you
// should register a glyph provider so FPDFEMB can get glyph bitmap for each character.

/**
 * @name Charset defines.
 */
/*@{*/

/** @brief Default. */
#define FPDFEMB_CHARSET_DEFAULT		0
/** @brief For simplified Chinese. */
#define FPDFEMB_CHARSET_GB			936
/** @brief For traditional Chinese. */
#define FPDFEMB_CHARSET_BIG5		950
/** @brief For Japanese. */
#define FPDFEMB_CHARSET_JIS			932
/** @brief For Korea. */
#define FPDFEMB_CHARSET_KOREA		949
/** @brief Unicode. */
#define FPDFEMB_CHARSET_UNICODE		1200

/*@}*/

/**
 * @name Font flags.
 */
/*@{*/

/** @brief Fixed pitch. */
#define FPDFEMB_FONT_FIXEDPITCH		1
/** @brief Serif. */
#define FPDFEMB_FONT_SERIF			2
/** @brief Symbolic. */
#define FPDFEMB_FONT_SYMBOLIC		4
/** @brief Script. */
#define FPDFEMB_FONT_SCRIPT			8
/** @brief Non-symbolic. */
#define FPDFEMB_FONT_NONSYMBOLIC	32
/** @brief Italic. */
#define FPDFEMB_FONT_ITALIC			64
/** @brief All cap. */
#define FPDFEMB_FONT_ALLCAP			0x10000
/** @brief Small cap. */
#define FPDFEMB_FONT_SMALLCAP		0x20000
/** @brief Force bold. */
#define FPDFEMB_FONT_FORCEBOLD		0x40000

/*@}*/

/**
 * @brief Structure: FPDFEMB_FONT_MAPPER
 *			Defines interface for system font mapper.
 */
struct FPDFEMB_FONT_MAPPER
{
	/**
	 * Interface: MapFont
	 * 		Find font file path for a particular PDF font
	 *
	 * @param[in] mapper		Pointer to the FPDFEMB_FONT_MAPPER structure
	 * @param[in] name			Font name
	 * @param[in] charset		Charset ID (see above FPDFEMB_CHARSET_xxx constants)
	 * @param[in] flags			Font flags (see above FPDFEMB_FONT_xxx constants)
	 * @param[in] weight		Weight of the font. Range from 100 to 900. 400 is normal,
	 * 							700 is bold.
	 * @param[out] path			Receiving the full file path. The buffer size is 512 bytes.
	 * @param[out] face_index	Receiving an zero-based index value for the font face, if the 
	 * 							mapped font file is a "collection" (meaning a number of faces 
	 *							are stored in the same file). If the font file is not a 
	 *							collection, the index value should be zero.
	 * @return	Non-zero for a substitution font has be specified.
	 *			Zero if the mapper doesn't map the font, or something is wrong.
	 */
	FPDFEMB_BOOL	(*MapFont)(struct FPDFEMB_FONT_MAPPER* mapper, const char* name, int charset,
									unsigned int flags,	int weight,
									char* path, int* face_index);

	void*		user;		/**< A user pointer, used by the application. */
};

/**
 * Function: FPDFEMB_SetFontMapper
 *			Use a system font mapper (typically for Chinese/Japanese/Korean charsets)
 *
 * Comments:
 *			This function is used with devices that come with one or more system fonts,
 *			and those fonts are in standard TT or T1 format.
 *
 * @param[in] mapper			Pointer to FPDFEMB_FONT_MAPPER structure.
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_SetFontMapper(struct FPDFEMB_FONT_MAPPER* mapper);

/**
 * @brief Structure: FPDFEMB_FONT_MAPPEREx
 *			Defines interface for system font mapper.
 */
struct FPDFEMB_FONT_MAPPEREx
{
	 /**
	 * Interface: MapFontEx
	 * 		Find font Data for a particular PDF font
	 *
	 * @param[in] mapper		Pointer to the FPDFEMB_FONT_MAPPEREx structure
	 * @param[in] name			Font name
	 * @param[in] charset		Charset ID (see above FPDFEMB_CHARSET_xxx constants)
	 * @param[in] flags			Font flags (see above FPDFEMB_FONT_xxx constants)
	 * @param[in] weight		Weight of the font. Range from 100 to 900. 400 is normal,
	 * 							700 is bold.
	 * @param[out] fontdata		Pointer to the external data.
	 * @param[out] fontsize     Number of bytes in the external data.
 	 * @param[out] face_index	Receiving an zero-based index value for the font face, if the 
	 * 							mapped font file is a "collection" (meaning a number of faces 
	 *							are stored in the same file). If the font file is not a 
	 *							collection, the index value should be zero.
	 * @return	Non-zero for a substitution font has be specified.
	 *			Zero if the mapper doesn't map the font, or something is wrong.
	 */
	FPDFEMB_BOOL	(*MapFontEx)(struct FPDFEMB_FONT_MAPPEREx* mapper, const char* name, int charset,
		unsigned int flags, int weight,
		 char** fontdata, int* fontsize,int* face_index);


	void*		user;		/**< A user pointer, used by the application. */
};

/**
 * Function: FPDFEMB_SetFontMapperEx
 *			Use a system font mapper (typically for Chinese/Japanese/Korean charsets)
 *
 * Comments:
 *			This function is used with devices that come with one or more system fonts,
 *			and those fonts are in standard TT or T1 format.
 *
 * @param[in] mapper			Pointer to FPDFEMB_FONT_MAPPER structure.
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_SetFontMapperEx(struct FPDFEMB_FONT_MAPPEREx* mapper);

/**
 * @brief Structure: FPDFEMB_GLYPH_PROVIDER
 *			Interface for providing glyph bitmap of non-latin characters.
 *			This is usually used for embedded devices with Chinese/Japanese/Korean 
 *			fonts installed, but those fonts are not in TrueType or Type1 format.
 */
struct FPDFEMB_GLYPH_PROVIDER
{
	/**
	 * Interface: MapFont
	 * 		Return an internal handle for a font
	 * 
	 * @param[in] provider		Pointer to this structure
	 * @param[in] name			Font name
	 * @param[in] charset		Charset ID (see above FPDFEMB_CHARSET_xxx constants)
	 * @param[in] flags			Font flags (see above FPDFEMB_FONT_xxx constants)
	 * @param[in] weight		Weight of the font. Range from 100 to 900. 400 is normal,
	 * 						700 is bold.
	 * @return	An internal handle to the mapped font. If the embedded device supports
	 *		multiple fonts, then this value can serve as an identifier to differentiate
	 *		among them. If the device supports only one font, then implementation of
	 *		this function can simply return NULL.
	 */
	void*	(*MapFont)(struct FPDFEMB_GLYPH_PROVIDER* provider, const char* name, int charset,
									unsigned int flags,	int weight);
	/**
	 * Interface: GetGlyphBBox
	 *		Get glyph bounding box
	 *
	 * Comments:
	 *		The bounding box is measure in a glyph coordination system, in which the
	 *		origin is set to character origin, and unit is set to one-thousandth of
	 *		"em size" (representing the font size).
	 *
	 *		In most CJK fonts, all CJK characters (except some symbols or western 
	 *		characters) have same glyph bounding box:
	 *		left = 0, right = 1000, bottom = -220, top = 780.
	 *
	 *		It's OK to return a box that's larger than the actual glyph box.
	 *
	 * @param[in] provider		Pointer to this structure
	 * @param[in] font			Internal handle to the font. Returned by MapFont interface.
	 * @param[in] unicode		Unicode of the character
	 * @param[in] CID			Adobe CID for this character. Or zero if not available.
	 * @param[out] bbox			Receiving the result bounding box. See comments below.
	 */
	void	(*GetGlyphBBox)(struct FPDFEMB_GLYPH_PROVIDER* provider, void* font,
									FPDFEMB_WCHAR unicode, unsigned short CID,
									struct FPDFEMB_RECT* bbox);

	/**
	 * Interface: GetGlyphBitmap
	 *		Get bitmap of a glyph
	 *
	 * Comments:
	 * 		The buffer should be allocated by implementation. And it must be allocated
	 *		using FPDFEMB_AllocMemory function. The result buffer will be destroyed by
	 *		FPDFEMB SDK, so implementation should not destroy it.
	 *
	 *		The implementation should write "coverage" data into allocated buffer, one byte 
	 *		for each pixel, from top scanline to bottom scanline, within each scan line, 
	 *		from left pixel to right. Coverage 0 means the pixel is outside the glyph, 
	 *		coverage 255 means the pixel is inside the glyph.
	 *
	 *		The "pdf_width" parameter can be used to scale the character in system font
	 *		horizontally to match the font width specified in PDF. For example, if we have
	 *		a PDF file which requires a character in half-width (pdf_width is 500), but
	 *		in the system font the character has full-width (1000), then the glyph provider
	 *		implementation should scale the font horizontally to half of its original width.
	 *
	 * @param[in] provider		Pointer to this structure
	 * @param[in] font			Internal handle to the font. Returned by MapFont interface.
	 * @param[in] unicode		Unicode of the character
	 * @param[in] CID			Adobe CID for this character. Or zero if not available.
	 * @param[in] font_width	Width of the font em square, measured in device units.
	 * @param[in] font_height	Height of the font em square, measured in device units.
	 * @param[out] left			Receiving the left offset, from the character origin, of the
	 *							result glyph bitmap. Positive value will move the bitmap to
	 *							the right side, negative to the left.
	 * @param[out] top			Receiving the top offset, from the character origin, of the
	 *	 						result glyph bitmap. Positive value will move the bitmap upward,
	 *							negative downward.
	 * @param[out] bitmap_width		Receiving number of width pixels in the result bitmap
	 * @param[out] bitmap_height	Receiving number of height pixels in the result bitmap
	 * @param[out] buffer		Receiving a data buffer pointer, allocated by the implementation.
	 *							See comments below.
	 * @param[out] stride		Receiving number of bytes per scanline, in the data buffer.
	 * @param[in] pdf_width		Width of the character specified in PDF. It is measured in one-
	 *							thousandth of the font width. It can be 0 if width not specified
	 *							in PDF. See comments below.
	 * @return Non-zero for success. 0 for failure. In this case the glyph can not be displayed.
	 */
	FPDFEMB_BOOL (*GetGlyphBitmap)(struct FPDFEMB_GLYPH_PROVIDER* provider, void* font,
									FPDFEMB_WCHAR unicode, unsigned short CID,
									double font_width, double font_height, int* left, int* top,
									int* bitmap_width, int* bitmap_height, 
									void** buffer, int* stride, int pdf_width);

	void*		user;		/**< A user pointer, used by the application. */
};

/**
 * Function: FPDFEMB_SetGlyphProvider
 *			Make use of a glyph provider: generating glyph bitmap for non-Latin characters
 *
 * Comments:
 *			FPDFEMB embeds some standard fonts for Latin characters and symbols, like
 *			Times, Courier and Helvetica (Arial). For non-Latin characters, however,
 *			FPDFEMB has to ask glyph provide for help.
 *
 *			If an embedded device carries fonts for non-Latin character sets, especially
 *			those for CJK markets, then the application can implement a glyph provider,
 *			allowing PDFs using non-embedded CJK fonts to be properly displayed.
 *
 * @param[in] provider		Pointer to the glyph provider structure.
 *							This structure must stay valid throughout usage of FPDFEMB module.
 */
void FPDFEMB_SetGlyphProvider(struct FPDFEMB_GLYPH_PROVIDER* provider);

/**
 * Function: FPDFEMB_UseExternalCMaps
 *			Make use of external data for FPDFEMB
 *
 * Comments:
 *			Some embedded system has limitation on program size, therefore we might not be able to
 *			embed a lot of data (like cmap data and embedded font data) into the FPDFEMB library. 
 *			We introduced this function so device can choose to store those data outside of program, 
 *			and make it available to FPDFEMB using this function. The data has to be provided by Foxit.
 *
 *			This function is only available in library specially built for using external data.
 *
 * @param[in]	data		Pointer to the external data
 * @param[in]	size		Number of bytes in the external data.
 */
void FPDFEMB_UseExternalData(const unsigned char* data, unsigned int size);




/**
 * Function: FPDFEMB_UseFontDataEx
 *			Make use of external data for FPDFEMB
 *
 * Comments:
 *			Some embedded system has limitation on program size, therefore we might not be able to
 *			embed a lot of data (like cmap data and embedded font data) into the FPDFEMB library. 
 *			We introduced this function so device can choose to store those data outside of program, 
 *			and make it available to FPDFEMB using this function. The data has to be provided by Foxit.
 *
 *			This function is only available in library specially built for using external data.
 *
 * @param[in]	data		Pointer to the external data
 * @param[in]	size		Number of bytes in the external data.
 */
void FPDFEMB_UseFontDataEx(const unsigned char* data, unsigned int size, int* face_index);

/**
 * Function: FPDFEMB_LoadCMap_GB
 * Function: FPDFEMB_LoadCMap_GB_Ext
 * Function: FPDFEMB_LoadCMap_CNS
 * Function: FPDFEMB_LoadCMap_Korean
 * Function: FPDFEMB_LoadCMap_Japan
 * Function: FPDFEMB_LoadCMap_Japan_Ext
 *			Make use of character encoding maps embedded with FPDFEMB
 *
 * Comments:
 *			These functions add character encoding data to your application. Each call
 *			will increase the code size of your application. Total data size for all
 *			character sets is around 434K bytes.
 */
void FPDFEMB_LoadCMap_GB();
/**
 * Load full code table for GB.
 *
 * @see FPDFEMB_LoadCMap_GB()
 */
void FPDFEMB_LoadCMap_GB_Ext();
/** @see FPDFEMB_LoadCMap_GB() */
void FPDFEMB_LoadCMap_CNS();
/** @see FPDFEMB_LoadCMap_GB() */
void FPDFEMB_LoadCMap_Korea();
/** @see FPDFEMB_LoadCMap_GB() */
void FPDFEMB_LoadCMap_Japan();
/**
 * Load full code table for Japan.
 *
 * @see FPDFEMB_LoadCMap_GB()
 */
void FPDFEMB_LoadCMap_Japan_Ext();

/********************************************************************************************
****
****		Document Information
****
********************************************************************************************/

/**
 * Function: PDFEMB_GetDocInfoString
 *			Get information string about the document, like creator, modification date, etc.
 *
 * Comments:
 *			The string is output in Unicode, using UTF-16LE format. It's terminated by
 *			two consecutive zero bytes.
 *
 *			If the "buffer" parameter is NULL, then the "bufsize" parameter will receive
 *			number of bytes required to store the string (including the two-byte terminator).
 *
 * @param[in] document		Handle to the document
 * @param[in] key			A byte string for the information key. Currently can be one of the followings:
 *							"Title", "Author", "Subject", "Keywords", "Creator", "Producer", "CreationDate",
 *							"ModDate", or some custom information key, if supported by the PDF file.
 * @param[out] buffer		A buffer allocated by the application, or NULL.
 * @param[in,out] bufsize	A pointer to a number indicating the buffer size (number of bytes),
 *							before this function call. After return, this place will store
 *							number of bytes used by the output (including terminator).
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_GetDocInfoString(FPDFEMB_DOCUMENT document, const char* key, void* buffer, unsigned int* bufsize);

/********************************************************************************************
****
****		Action (Destination) Information
****
********************************************************************************************/

/** @brief PDF action handle type. */
typedef void* FPDFEMB_ACTION;

/**
 * @name Action types supported by FPDFEMB
 */
/*@{*/

/** @brief No or unsupported destination. */
#define FPDFEMB_DEST_NONE			0
/** @brief A page inside the same document. */
#define FPDFEMB_DEST_PAGE			1
/** @brief An external PDF document. */
#define FPDFEMB_DEST_DOC			2
/** @brief An external URL. */
#define FPDFEMB_DEST_URL			3
/** @brief Launch an external file or command. */
#define FPDFEMB_ACTION_LAUNCH		4

/*@}*/

/**
 * @name Zoom mode for destination.
 */
/*@{*/

/** @brief Zoom mode not specified. */
#define FPDFEMB_ZOOM_NONE			0
/** @brief Specific zoom factor is used. */
#define FPDFEMB_ZOOM_FACTOR			1
/** @brief Fit the whole page on screen. */
#define FPDFEMB_ZOOM_FITPAGE		2
/** @brief Fit width of the page on screen. */
#define FPDFEMB_ZOOM_FITWIDTH		3
/** @brief Fit height of the page on screen. */
#define FPDFEMB_ZOOM_FITHEIGHT		4
/** @brief Fit a particular rectangle on screen. */
#define FPDFEMB_ZOOM_FITRECT		5
/** @brief Fit whole content of page on screen. */
#define FPDFEMB_ZOOM_FITCONTENT		6
/** @brief Fit content width of page on screen. */
#define FPDFEMB_ZOOM_FITCONTENTW	7
/** @brief Fit content height of page on screen. */
#define FPDFEMB_ZOOM_FITCONTENTH	8

/*@}*/

/** @brief Data structure for page destination. */
struct FPDFEMB_PAGEDEST
{
	int				page_index;		/**< Zero based index for the page. */
	int				zoom_mode;		/**< See FPDFEMB_ZOOM_xxx definition above. */
	int				zoom_factor;	/**< For FPDFEMB_ZOOM_FACTOR only: the zoom factor (in percentage). */
	/**
	 * Specify position inside the page. Depends on the zoom mode,
	 * different members of the rectangle are used:\n
	 * - FPDFEMB_ZOOM_NONE:			left, top
	 * - FPDFEMB_ZOOM_FACTOR:		left, top
	 * - FPDFEMB_ZOOM_FITPAGE:		none
	 * - FPDFEMB_ZOOM_FITWIDTH:		top
	 * - FPDFEMB_ZOOM_FITHEIGHT:	left
	 * - FPDFEMB_ZOOM_FITRECT:		left, top, bottom, right
	 * - FPDFEMB_ZOOM_FITCONTENT:	none
	 * - FPDFEMB_ZOOM_FITCONTENTW:	top
	 * - FPDFEMB_ZOOM_FITCONTENTH:	left
	 */
	struct FPDFEMB_RECT	position;
};

/** @brief Data structure for document destination. */
struct FPDFEMB_DOCDEST
{
	struct FPDFEMB_PAGEDEST	page_data;	/**< page data. */
	char*				file_name;	/**< The file name, encoded in original charset (maybe MBCS). */
};

/** @brief Data structure for URL destination. */
struct FPDFEMB_URLDEST
{
	char*				url;		/**< URL encoded in 7-bit ASCII. */
};

/** @brief Data structure for Launch action. */
struct FPDFEMB_LAUNCHACTION
{
	int					new_window;	/**< Whether a new window should be opened. */
	char*				file_name;	/**< The file name, encoded in original charset (maybe MBCS). */
};

/**
 * Function: FPDFEMB_Action_GetType
 *			Get type of an action
 *
 * Comments:
 *			Each different type of destination has different data structure. The "data_size" result
 *			indicates how many bytes is required to hold the destination data structure. The application
 *			can then allocate sufficient buffer and then call FPDFEMB_Bookmark_GetDest function to
 *			get the real data.
 *
 * @param[in] document		Handle to the document
 * @param[in] action		Handle to the action
 * @param[out] dest_type	Pointer to an integer receiving type of the destination. See the above
 *							FPDFEMB_DEST_xxx definitions
 * @param[out] data_size	Pointer to an integer receiving data block size for the destination.
 *							If this parameter is NULL, then data size won't be retrieved.
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_Action_GetType(FPDFEMB_DOCUMENT document, FPDFEMB_ACTION action, int* dest_type, int* data_size);

/**
 * Function: FPDFEMB_Action_GetData
 *			Get detailed data of a particular action
 * Comments:
 *			See data structure definition for different action type above. Please note
 *			the actual action data might use more space than the structure definition
 *			shows, to store things like file name or URL. So you should always call
 *			FPDFEMB_Action_GetType first to get data size then allocate enough buffer
 *			for this call.
 *
 * @param[in] document		Handle to the document
 * @param[in] action		Handle to the action
 * @param[out] buffer		Application allocated buffer receiving the destination data
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_Action_GetData(FPDFEMB_DOCUMENT document, FPDFEMB_ACTION action, void* buffer);

/**
 * Function: FPDFEMB_Action_GetNext
 *			Get next action in an action chain
 *
 * Comments:
 *			If there is no next action, the "next" parameter will be set to NULL after the function returns.
 *
 * @param[in] action		Handle to current action
 * @param[out] next			Receiving handle to next action.
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_Action_GetNext(FPDFEMB_ACTION action, FPDFEMB_ACTION* next);

/********************************************************************************************
****
****		Bookmark Information
****
********************************************************************************************/

/** @brief PDF bookmark handle type. */
typedef void* FPDFEMB_BOOKMARK;

/**
 * Function: FPDFEMB_Bookmark_GetFirstChild
 *			Get first child of a bookmark item, or first top level bookmark item
 *
 * @param[in] document		Handle to the document
 * @param[in] parent		Handle to the parent bookmark. 
 *							Can be NULL if you want to get the first top level item.
 * @param[out] bookmark		Receiving handle to the first child or top level bookmark item. 
 *							If result is NULL, then bookmark not found.
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_Bookmark_GetFirstChild(FPDFEMB_DOCUMENT document, FPDFEMB_BOOKMARK parent,
											  FPDFEMB_BOOKMARK* bookmark);

/**
 * Function: FPDFEMB_Bookmark_GetNextSibling
 *			Get next sibling of a bookmark item
 *
 * @param[in] document		Handle to the document
 * @param[in] bookmark		Handle to the bookmark 
 * @param[out] sibling		Receiving the handle of next sibling.
 *							If result is NULL, then this is the last bookmark in this level.
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_Bookmark_GetNextSibling(FPDFEMB_DOCUMENT document, FPDFEMB_BOOKMARK bookmark,
											  FPDFEMB_BOOKMARK* sibling);

/**
 * Function: FPDFEMB_Bookmark_GetTitle
 *			Get title of a bookmark
 *
 * Comments:
 *			The title is output in Unicode, using UTF-16LE format. It's terminated by
 *			two consecutive zero bytes.
 *
 *			If the "buffer" parameter is NULL, then the "bufsize" parameter will receive
 *			number of bytes required to store the bookmark title (including the two-
 *			byte terminator).
 *
 *			If the buffer provided is smaller than the required size, then this function
 *			will not copy any data, return FPDFEMB_PARAM, and the required buffer size will 
 *			also be put in "bufsize" parameter.
 *
 * @param[in] bookmark		Handle to the bookmark 
 * @param[out] buffer		A buffer allocated by the application, or NULL.
 * @param[in,out] bufsize	A pointer to a number indicating the buffer size,
 *							before this function call. After return, this place will store
 *							number of bytes used by the output (including terminator).
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_Bookmark_GetTitle(FPDFEMB_BOOKMARK bookmark, void* buffer, unsigned int* bufsize);

/**
 * Function: FPDFEMB_Bookmark_GetPage
 *			Get page number of a bookmark pointing to
 *
 * Comments:
 *			Some bookmark might not point to a page, some bookmark might have more than one destination
 *			(action), for detailed information about a bookmark, you should call FPDFEMB_Bookmark_GetAction.
 *
 * @param[in] document		Handle to the document
 * @param[in] bookmark		Handle to the bookmark 
 * @param[out] page			Receiving the page number. -1 if this bookmark doesn't actually
 *							point to a page inside the document.
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_Bookmark_GetPage(FPDFEMB_DOCUMENT document, FPDFEMB_BOOKMARK bookmark, int* page);

/**
 * Function: FPDFEMB_Bookmark_GetAction
 *			Get action(s) associated with a particular bookmark
 *
 * @param[in] document		Handle to the document
 * @param[in] bookmark		Handle to the bookmark 
 * @param[out] action		Receiving handle of first action
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_Bookmark_GetAction(FPDFEMB_DOCUMENT document, FPDFEMB_BOOKMARK bookmark, FPDFEMB_ACTION* action);

/********************************************************************************************
****
****		Hyperlink Information
****
********************************************************************************************/

/**
 * Function: FPDFEMB_Link_GetCount
 *			Get number of hyperlinks inside a page
 *
 * Comments:
 *			This function must be called before any other link related function can
 *			be called for the page.
 *
 * @param[in] page			Page handle.
 * @param[out] link_count	Pointer to an integer receiving the number of links
 * @param[in] reserved		Must be zero now.
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_Link_GetCount(FPDFEMB_PAGE page, int* link_count, int reserved);

/**
 * Function: FPDFEMB_Link_GetAction
 *			Get action(s) associated with a particular hyperlink
 *
 * @param[in] page			Page handle
 * @param[in] link_index	Zero-based index for the link
 * @param[out] action		Receiving handle of first action
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_Link_GetAction(FPDFEMB_PAGE page, int link_index, FPDFEMB_ACTION* action);

/**
 * Function: FPDFEMB_Link_GetAreaCount
 *			Get number of area (quadrilaterals) for a link
 *
 * @param[in] page			Page handle
 * @param[in] link_index	Zero-based index for the link
 * @param[out] count		Pointer to an integer receiving number of quadrilaterals
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_Link_GetAreaCount(FPDFEMB_PAGE page, int link_index, int* count);

/**
 * Function: FPDFEMB_Link_GetArea
 *			Get a particular quadrilateral for a link
 *
 * Comments:
 *			The result in "points" array are the X/Y coordinations for the four vertices
 *			of the quadrilateral. Vertices are in the following order: lower left, lower
 *			right, upper right, upper left.
 *
 * @param[in] page			Page handle
 * @param[in] link_index	Zero-based index for the link
 * @param[in] area_index	Zero-based index for the quadrilateral
 * @param[out] points		-	Pointer to an array consists 4 points, receiving coordinations
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_Link_GetArea(FPDFEMB_PAGE page, int link_index, int area_index, 
									struct FPDFEMB_POINT* points);

/********************************************************************************************
****
****		Text Output
****
********************************************************************************************/

/** @brief PDF font handle type. */
typedef void* FPDFEMB_FONT;

/**
 * @name Standard font ID
 */
/*@{*/

/** @brief Courier. */
#define FPDFEMB_FONT_COURIER			0
/** @brief bold. Courier-Bold. */
#define FPDFEMB_FONT_COURIER_B			1
/** @brief bold italic. Courier-BoldOblique. */
#define FPDFEMB_FONT_COURIER_BI			2
/** @brief italic. Courier-Oblique. */
#define FPDFEMB_FONT_COURIER_I			3
/** @brief Helvetica. */
#define FPDFEMB_FONT_HELVETICA			4
/** @brief bold. Helvetica-Bold. */
#define FPDFEMB_FONT_HELVETICA_B		5
/** @brief bold italic. Helvetica-BoldOblique. */
#define FPDFEMB_FONT_HELVETICA_BI		6
/** @brief italic. Helvetica-Oblique. */
#define FPDFEMB_FONT_HELVETICA_I		7
/** @brief Times-Roman. */
#define FPDFEMB_FONT_TIMES				8
/** @brief bold. Times-Bold. */
#define FPDFEMB_FONT_TIMES_B			9
/** @brief bold italic. Times-BoldItalic. */
#define FPDFEMB_FONT_TIMES_BI			10
/** @brief italic. Times-Italic. */
#define FPDFEMB_FONT_TIMES_I			11
/** @brief Symbol. */
#define FPDFEMB_FONT_SYMBOL				12
/** @brief ZapfDingbats. */
#define FPDFEMB_FONT_ZAPF_DINGBATS		13

/*@}*/

/**
 * Function: FPDFEMB_OpenStandardFont
 *			Get ready to use a standard PDF font
 *
 * @param[in] font_id			ID of font. See the above FPDFEMB_FONT_XXX definitions.
 * @param[out] font_handle		Receiving the font handle.
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_OpenStandardFont(int font_id, FPDFEMB_FONT* font_handle);

/**
 * Function: FPDFEMB_OpenFileFont
 *			Load a font from a file
 *
 * Comments:
 *			FPDFEMB only supports TrueType or Type1 font.
 *
 * @param[in] file			Pointer to file access structure.
 *							This structure must be kept valid as long as the font is open.
 * @param[out] font_handle	Receiving the font handle.
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_OpenFileFont(struct FPDFEMB_FILE_ACCESS* file,  FPDFEMB_FONT* font_handle);

/**
 * Function: FPDFEMB_CloseFont
 *			Close a font handle.
 *
 * @param[in] font_handle	Handle to the font.
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_CloseFont(FPDFEMB_FONT font_handle);

/**
 * @name Font encodings
 */
/*@{*/

/** @brief Whatever internal encoding in the font. */
#define FPDFEMB_ENCODING_INTERNAL		0
/** @brief Unicode encoding. */
#define FPDFEMB_ENCODING_UNICODE		1

/*@}*/

/**
 * Function: FPDFEMB_GetGlyphIndex
 *			Get glyph index of a character
 *
 * @param[in] font_handle	Handle to the font.
 * @param[in] encoding		Encoding, see the above FPDFEMB_ENCODING_XXX definitions
 * @param[in] char_code		Character code, depends on the encoding used. For example, if "encoding"
 * 							is FPDFEMB_ENCODING_UNICODE, then "char_code" should be unicode.
 * @param[out] glyph_index	Receiving the result glyph index.

 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_GetGlyphIndex(FPDFEMB_FONT font_handle, int encoding, unsigned long char_code,
									 unsigned long* glyph_index);

/**
 * Function: FPDFEMB_GetGlyphWidth
 *			Get width of a glyph in a font
 *
 * @param[in] font_handle		Handle to the font.
 * @param[in] glyph_index		Index of the glyph in font.
 * @param[out] width			Receiving the character width, in 1/1000 of design size (em)
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_GetGlyphWidth(FPDFEMB_FONT font_handle, unsigned long glyph_index, unsigned long* width);

/** @brief Text matrix for FPDFEMB. */
struct FPDFEMB_TEXTMATRIX
{
	double	a, b, c, d;
};
/**
 * Function: FPDFEMB_GetGlyphBitmapBearing
 *			Get bitmap bearing of a glyph in a font
 *
 * @param[in] font_handle		Handle to the font.
 * @param[in] glyph_index		Index of the glyph in font.
 * @param[in] matrix			Matrix for the glyph. Can be NULL.
 * @param[in] font_size			Font size in pixels.
 * @param[out] bitmap_left	    Receiving the glyph bitmap's left bearing expressed in integer pixels.
 * @param[out] bitmap_top	    Receiving the glyph bitmap's top bearing expressed in integer pixels.
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
 FPDFEMB_RESULT FPDFEMB_GetGlyphBitmapBearing(FPDFEMB_FONT font_handle, unsigned long glyph_index, struct FPDFEMB_TEXTMATRIX* matrix, double font_size, int *bitmap_left, int *bitmap_top);

/**
 * Function: FPDFEMB_OutputGlyph
 *			Output a glyph onto a DIB device
 *
 * @param[in] dib			DIB handle, as the output device
 * @param[in] x				DIB x-coordination for the glyph origin
 * @param[in] y				DIB y-coordination for the glyph origin.
 * @param[in] font_handle	Handle to the font
 * @param[in] font_size		Font size in pixels
 * @param[in] matrix		Matrix for the text output. Can be NULL.
 * @param[in] glyph_index	Index of glyph to be output
 * @param[in] argb			Color of the text, in 0xaarrggbb format.
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_OutputGlyph(FPDFEMB_BITMAP dib, int x, int y, FPDFEMB_FONT font_handle, double font_size,
								  struct FPDFEMB_TEXTMATRIX* matrix, unsigned long glyph_index, unsigned long argb);

/**
 * Function: FPDFEMB_OutputText
 *			Output text string onto a DIB device.
 *
 * @param[in] dib			DIB handle, as the output device
 * @param[in] x				DIB x-coordination for the origin point of the first character.
 * @param[in] y				DIB y-coordination for the origin point of the first character.
 * @param[in] font_handle	Handle to the font
 * @param[in] font_size		Font size in pixels
 * @param[in] matrix		Matrix for the text output. Can be NULL.
 * @param[in] text			Zero-terminated unicode text string
 * @param[in] argb			Color of the text, in 0xaarrggbb format.
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_OutputText(FPDFEMB_BITMAP dib, int x, int y, FPDFEMB_FONT font_handle, double font_size,
								  struct FPDFEMB_TEXTMATRIX* matrix, const FPDFEMB_WCHAR* text, unsigned long argb);

/**
 * Function: FPDFEMB_SetLogProc
 *			Set a logging procedure to output debugging messages from FPDFEMB
 *
 * @param[in] proc			A callback function for output logging info
 */
void FPDFEMB_SetLogProc(void (*proc)(const char* msg));

/**
 * Function: FPDFEMB_GetContentMargin
 *			Get content margin
 *
 * @param[in] page			Page handle
 * @param[out] left			Receiving the left margin (in hundredth of points)
 * @param[out] top			Receiving the top margin (in hundredth of points)
 * @param[out] right			Receiving the right margin (in hundredth of points)
 * @param[out] bottom		Receiving the bottom margin (in hundredth of points)
 * @param[in] backcolor		Color for intended background in the page. In 0xRRGGBB format.
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_GetContentMargin(FPDFEMB_PAGE page, int* left, int* top, int* right, int* bottom, 
								  unsigned long backcolor/*=0xfffffff*/);


/**
 * Function: FPDFEMB_GetPageLabel
 *			Get Page label
 *
 * Comments:
 *			The string is output in Unicode, using UTF-16LE format. It's terminated by
 *			two consecutive zero bytes.
 *
 *			If the "buffer" parameter is NULL, then the "bufsize" parameter will receive
 *			number of bytes required to store the string (including the two-byte terminator).
 *
 * @param[in] document		Handle to the document
 * @param[out] nPage		Page index
 * @param[out] buffer		A buffer allocated by the application, or NULL.
 * @param[in,out] bufsize	A pointer to a number indicating the buffer size (number of bytes),
 *							before this function call. After return, this place will store
 *							number of bytes used by the output (including terminator).
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_GetPageLabel(FPDFEMB_DOCUMENT document, int nPage, void* buffer, unsigned int* bufsize);

/**
 * Function: FPDFEMB_PageLabelToPageNum
 *			Get Page Number by Page Label
 *
 * @param[in] document		Handle to the document
 * @param[in] pagelabel		A zero-terminated unicode page label string to be found. 
 * @param[out] pageNum		Receiving the found page number
 * @return  Error code, or FPDFERR_SUCCESS for success.
 *			If not found, FPDFERR_NOTFOUND is returned.
 */
FPDFEMB_RESULT FPDFEMB_PageLabelToPageNum(FPDFEMB_DOCUMENT document, FPDFEMB_WCHAR* pagelabel,int* pageNum);

/**
 * Function: FPDFEMB_PageLabelToPageNumNoCase
 *			Get Page Number by Page Label
 *
 * @param[in] document		Handle to the document
 * @param[in] pagelabel		A zero-terminated unicode page label string to be found. 
 * @param[out] pageNum		Receiving the found page number
 * @return  Error code, or FPDFERR_SUCCESS for success.
 *			If not found, FPDFERR_NOTFOUND is returned.
 */
FPDFEMB_RESULT FPDFEMB_PageLabelToPageNumNoCase(FPDFEMB_DOCUMENT document, FPDFEMB_WCHAR* pagelabel, int* pageNum);

/**
 * Function: FPDFEMB_IsDirectionR2L
 *			Determine if the predominant reading order for text is from right to left. 
 *			The "Direction" entry found in Catalog dictionary > ViewerPreferences dictionsary > Direction name.
 *			See "Direction" in PDF reference for more information.
 *
 * @param[in]	Handle to the document.
 * @param[out]  True indicates the reading direction is right to left. False indicates left to 
 *				right (default according to PDF Reference). 
 * @return		Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_IsDirectionR2L(FPDFEMB_DOCUMENT document, FPDFEMB_BOOL *isR2L);

#ifdef __cplusplus
};
#endif

#endif	// #ifdef _FPDFEMB_H_

/** @} */
